package com.ruoyi.performance.service.impl;

import java.util.List;

import com.ruoyi.common.utils.SecurityUtils;
import com.ruoyi.teacher.domain.Teacher;
import com.ruoyi.teacher.mapper.TeacherMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.performance.mapper.MonthlySummaryMapper;
import com.ruoyi.performance.domain.MonthlySummary;
import com.ruoyi.performance.service.IMonthlySummaryService;

import javax.annotation.Resource;

/**
 * 月度数据汇总Service业务层处理
 * 
 * @author eden
 * @date 2023-05-19
 */
@Service
public class MonthlySummaryServiceImpl implements IMonthlySummaryService 
{
    @Autowired
    private MonthlySummaryMapper monthlySummaryMapper;
    @Resource
    private TeacherMapper teacherMapper;

    /**
     * 查询月度数据汇总
     * 
     * @param id 月度数据汇总主键
     * @return 月度数据汇总
     */
    @Override
    public MonthlySummary selectMonthlySummaryById(Long id)
    {
        return monthlySummaryMapper.selectMonthlySummaryById(id);
    }

    /**
     * 查询月度数据汇总列表
     * 
     * @param monthlySummary 月度数据汇总
     * @return 月度数据汇总
     */
    @Override
    public List<MonthlySummary> selectMonthlySummaryList(MonthlySummary monthlySummary)
    {
        return monthlySummaryMapper.selectMonthlySummaryList(monthlySummary);
    }

    /**
     * 新增月度数据汇总
     * 
     * @param monthlySummary 月度数据汇总
     * @return 结果
     */
    @Override
    public int insertMonthlySummary(MonthlySummary monthlySummary)
    {
        Long userId = SecurityUtils.getUserId();
        userId = 109l;
        Teacher teacher = teacherMapper.findByUserId(userId);

        monthlySummary.setTeacherName(teacher.getName());
        return monthlySummaryMapper.insertMonthlySummary(monthlySummary);
    }

    /**
     * 修改月度数据汇总
     * 
     * @param monthlySummary 月度数据汇总
     * @return 结果
     */
    @Override
    public int updateMonthlySummary(MonthlySummary monthlySummary)
    {
        return monthlySummaryMapper.updateMonthlySummary(monthlySummary);
    }

    /**
     * 批量删除月度数据汇总
     * 
     * @param ids 需要删除的月度数据汇总主键
     * @return 结果
     */
    @Override
    public int deleteMonthlySummaryByIds(Long[] ids)
    {
        return monthlySummaryMapper.deleteMonthlySummaryByIds(ids);
    }

    /**
     * 删除月度数据汇总信息
     * 
     * @param id 月度数据汇总主键
     * @return 结果
     */
    @Override
    public int deleteMonthlySummaryById(Long id)
    {
        return monthlySummaryMapper.deleteMonthlySummaryById(id);
    }
}
